package com.fast.linkbeanadmin.enums;

import lombok.Getter;
import org.springframework.http.HttpStatus;

/**
 * @author ruan cai yuan
 * @version 1.0
 * @fileName com.fast.linkbeanadmin.enums.CodeEnum
 * @description: 所有状态码封装枚举
 * @since 2024/7/21 下午3:41
 */
@Getter
public enum CodeEnum {
    // 成功
    SUCCESS(200, "Success"),
    // 错误/异常
    ERROR(500, "Success"),
    // 警告
    WARN(601, "Success"),

    //============= HTTP状态码异常封装 =============
    NOT_FOUND(404, "资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不允许"),
    REQUEST_TIMEOUT(408, "请求超时"),
    CONFLICT(409, "资源冲突"),
    UNPROCESSABLE_ENTITY(422, "请求参数错误"),

    //权限不足(请先登录)
    UNAUTHORIZED(403, "权限不足(请先登录)"),

    BUSINESS_ERROR(601, "业务异常"),
    DUPLICATE_KEY_ERROR(604, "唯一性约束校验失败"),
    AUTHENTICATION_FAILED(606, "认证失败（用户名或密码不正确）"),
    DATABASE_ERROR(700, "数据库异常"),
    ;
    private final int code;
    private final String msg;

    CodeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
